1

Генерирую ключи RSA шифрования. Kак правильно сделать из них base64 для хранения и передачи и как правильно вернуть из base64 key ? Если можно, приведите пожалуйста пример кода для android.

//генерирую ключ
KeyPairGenerator pairGenerator = KeyPairGenerator.getInstance("RSA");
        KeyPair keyPair = pairGenerator.generateKeyPair();
        Key publicKey = keyPair.getPublic();
        Key privateKey = keyPair.getPrivate();

1 ответ 1

1
//ключ в base64 строку
byte[] encodedKey = key.getEncoded();
String base64Key = Base64.getEncoder().encodeToString(encodedKey);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.