not decrypting what I crypted

后端 未结 3 1423
轻奢々
轻奢々 2020-12-16 08:57

I have a weird problem...

Basing my solution on Decrypting a hardcoded file as byte[]

So, I wrote a small Cypher class to help out with crypting/decrypting..

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 09:10

    I think the problem is here:

    //opentext
    System.out.println("checking PEM...");
    crypted = Base64Coder.encode(getBytesFromFile(cryptoPEM));
    

    Previously, you wrote char[] to the file, but now you're reading a byte[] from the file and re-encoding in base64. The file's contents should already be base64-encoded!

    You need a new function called getCharsFromFile that returns char[] or String and pass that directly to decrypt2.

提交回复
热议问题