File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 189
189
<scope >test</scope >
190
190
</dependency >
191
191
192
+ <dependency >
193
+ <groupId >org.springframework.security</groupId >
194
+ <artifactId >spring-security-crypto</artifactId >
195
+ <version >6.3.1</version >
196
+ </dependency >
197
+
192
198
</dependencies >
193
199
194
200
Original file line number Diff line number Diff line change
1
+ package encryption ;
2
+
3
+ import org .springframework .security .crypto .keygen .BytesKeyGenerator ;
4
+ import org .springframework .security .crypto .keygen .KeyGenerators ;
5
+
6
+ public class SpringSecurityCryptoModule {
7
+ /**
8
+ * Reference: https://docs.spring.io/spring-security/site/docs/3.1.x/reference/crypto.html
9
+ */
10
+ public static void main (String ... args ) {
11
+ // BytesEncryptor encryptor = Encryptors.standard("password", "salt");
12
+
13
+ String salt = KeyGenerators .string ().generateKey (); // generates a random 8-byte salt that is then hex-encoded
14
+ System .out .println ("salt is: " + salt );
15
+
16
+ // TextEncryptor textEncryptor = Encryptors.text("password", "salt");
17
+
18
+ BytesKeyGenerator generator = KeyGenerators .secureRandom ();
19
+ byte [] key = generator .generateKey ();
20
+ System .out .println ("key is: " + key );
21
+
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments