Removing this piece of code as been moved to a new module. (#10820)

This commit is contained in:
Bhabani Prasad Patel
2021-05-29 16:53:38 +05:30
committed by GitHub
parent 06228886cf
commit 437fcd4915
2 changed files with 0 additions and 97 deletions

View File

@@ -1,44 +0,0 @@
package com.baeldung.secretkeyandstringconversion;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.SecretKey;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class ConversionClassUtilUnitTest {
@Test
void givenPasswordAndSalt_whenCreateSecreKeyCheckConversion_thenSuccess()
throws NoSuchAlgorithmException, InvalidKeySpecException {
// given
String password = "Baeldung@2021";
String salt = "@$#baelDunG@#^$*";
// when
SecretKey encodedKey = ConversionClassUtil.getKeyFromPassword(password, salt);
String encodedString = ConversionClassUtil.convertSecretKeyToString(encodedKey);
SecretKey decodeKey = ConversionClassUtil.convertStringToSecretKeyto(encodedString);
// then
Assertions.assertEquals(encodedKey, decodeKey);
}
@Test
void givenSize_whenCreateSecreKeyCheckConversion_thenSuccess()
throws NoSuchAlgorithmException, InvalidKeySpecException {
// given
int size = 256;
// when
SecretKey encodedKey = ConversionClassUtil.generateKey(size);
String encodedString = ConversionClassUtil.convertSecretKeyToString(encodedKey);
SecretKey decodeKey = ConversionClassUtil.convertStringToSecretKeyto(encodedString);
// then
Assertions.assertEquals(encodedKey, decodeKey);
}
}