Public static final String PUBLIC_KEY_START_KEY_STRING = "-BEGIN PUBLIC KEY-" ![]() For that, we’ll use the following code snippet: public static final String NEW_LINE_CHARACTER = "\n" For that, once we have the file’s content into a variable, we’ll replace all the unwanted text with some empty strings. You need to remove all that and have only the key. ![]() Xy88xRksZqqEmgCwEX4gVsAWrGCTJ7U LyuSYpavbHGcUkA4rIh9XCkgphvXYod2ĬnyU0XQJ1jRLvTD4EozTtyA1wKRxtATj/2o swH3mnEW1y4weEoLmfcJ844tQU/lģDIxQh XWhzdsqo8kX Za8RAFbH2xbK yG6U3it5TrSwmsSSUh2ZGlcGiN76C/42ĦrTWS0lj5kYEUYKqON782ui8K2hGj9ylpL6lohosH8lsTKZvRK0PCs698QKrlc/MĪs you can see, there’s some text in there, and some new line characters, and some dashes. IuKd2AQwEBiJMt15djesw6wgR/1jWJr/ZUM XPIVkshHoPkhh2JhnqvEZt3VEYeY MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAut9/U5lR6UN/02YX79qv If you open up your public key file ( cat it or open it in a text editor), you’ll see something like this: -BEGIN PUBLIC KEY. We have to clean up the public key data though. ![]() Next, we need to read the public key file into our Java code. For that though, we need to first convert this string into a byte array: byte bytesToBeEncrypted = dataToBeEncrypted.getBytes() I have selected a very specific message to encrypt, and it makes a lot of sense: String dataToBeEncrypted = "Some random words in no particular order." Īs you can see, I can’t really send out this very sensitive message over public internet. Now that we have a key pair, let’s start encrypting our message.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |