Simple algorithm for mixing/obfuscating a string with pre-defined chars

后端 未结 5 632
北恋
北恋 2021-01-31 05:39

I have a string as follows:

  • Its length is 10.
  • It represents base 36 and as such includes digits and uppercase letters.
  • The origin of the st
5条回答
  •  被撕碎了的回忆
    2021-01-31 06:18

    What about having just an array with the 36 characters in a random order? Something like a One-time pad encryption but with a fixed pad:

    static String source="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    static String target="Q5A8ZWS0XEDC6RFVT9GBY4HNU3J2MI1KO7LP";
    
    public static String obfuscate(String s) {
        char[] result= new char[10];
        for (int i=0;i

    So a 10 characters string like "HELLO12345" becomes "0ZCCF2MI1K". Obfuscated, but not encrypted

提交回复
热议问题