Java asymmetric encryption: preferred way to store public/private keys

前端 未结 3 500
陌清茗
陌清茗 2021-01-30 19:06

This code generates a pair of public/private keys:

KeyPairGenerator keyGen = KeyPairGenerator.getInstance(\"RSA\");
keyGen.initialize(1024);
KeyPair keypair = ke         


        
3条回答
  •  终归单人心
    2021-01-30 19:14

    If you want to define a format for storing the keys, then I would choose a format that is expendable so that it doesn't break when you want to change encryption (when the old one gets to weak for example).

    So i would store the bytes encoded as base64, together with a string that describes the format, "rsa" maybe.

提交回复
热议问题