Posts
Q&A
BCrypt ์ธ์ฆ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
(์ฌ์ง) ํ๋ก๊ทธ๋จ ์ฌ๊ฐ๋์ ๋ฐ๋๋๋ค. (์ ์ฝ๋ ํ ์คํธ ๊ฒฐ๊ณผ๋ fail๋๋๊ตฐ์..) ํ๋ก๊ทธ๋จ์ ์ฒ์ ์ด๊ธฐํ ํ ๊ฒฝ์ฐ ์์ฑ์์์ ์ํธ๋ฅผ ๋๋ค ์์ฑํด์ ๋ฃ์ด์ฃผ๊ธฐ ๋๋ฌธ์ด์ฃ . ์์ ์ด๊ฒ์ ๋ํด์ ๋ค ๊ธ์ ์จ๋์๋๋ฐ์. ์ ๊ฐ ๊ทธ๋์ ์๋ฌธ์ ์ด ์๊ธด๊ฒ์ด ๊ทธ๋ฌ๋ฉด ์ด๋ป๊ฒ ์ธ์ฝ๋๋ ํ๋ก๊ทธ๋จ์ ์ฌ๊ฐ๋ํ์๋ ์ํธ๋ฅผ ์ ์ ์๋ ? ์ด๊ฒ ์ด์์ต๋๋ค. ์๋ํ๋ฉด ๊ทธ ๋ถ๋ถ์ ์ ํํ ์ดํด๊ฐ ์๋๋ค๋ฉด ํ๋ก๊ทธ๋จ ๊ฐ๋ฐ์ ํ๊ณ ๋ ์ฐ์ฐํ ์ ๋ฐ์ ์๊ธฐ ๋๋ฌธ์ด์ฃ . ----------------------------------------------------------------------------------------------- ํ ์คํธ ๊ฒฐ๊ณผ ์๋์ธ์ฝ๋ฉ๋ ํจ์ค์๋๋ฅผ ์ํธ๋ก ์ ๊ณตํ๋ฉด ์ด๋ป๊ฒ ์์๋ด๋๊ฒ์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง ๊ทธ ์ ์ ์ด๋ค ์ํธ ๊ฐ์ ๋ฃ์๋์ง ๋ชฐ๋ผ๋ ๊ฐ์ ์ธ์ฝ๋ฉ ๊ฒฐ๊ณผ๊ฐ ๋์ค๊ฒ ๋ฉ๋๋ค. ๋ฌผ๋ก ์ด ๋ด์ฉ๋ ์ ๊ธ์์ ๋ค ์จ๋์์ต๋๋ค.. BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();String firstEncoded = passwordEncoder.encode("password");String secondEncoded = passwordEncoder.encode("password");System.out.println(firstEncoded);System.out.println(secondEncoded);$2a$10$bGPFYVPMIodBr3kPBNiA4u8MmOoqeDaTTqwSvwks57Qyci4fjNltK $2a$10$1OxvWR6cYdJYO6/QSFHHDeevmbuaCirH4ZJdezwKzihHuVnlwMynG$2a$10$h0GZ96jg5BR2QDQxWtxQKuehwx.VLOw2QYFQX0PXmZhT94Eh6kPki $2a$10$m.e0/kCIsuY3NODsVVw8xu0JZrprfY3Y2YhFduCEUOWLlpJFHUq1a BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();String firstEncoded = BCrypt.hashpw("password", "$2a$10$bGPFYVPMIodBr3kPBNiA4u8MmOoqeDaTTqwSvwks57Qyci4fjNltK");System.out.println(firstEncoded);$2a$10$bGPFYVPMIodBr3kPBNiA4u8MmOoqeDaTTqwSvwks57Qyci4fjNltK
- 1
- 9
- 1.5K
Q&A
์คํ๋ง์ด ์ปจํธ๋กค๋ฌ๋ฅผ ์ค์บํ์ง ์๋ ๋ฌธ์
ํ ์ง๋๊ฐ๋ ์ฌ๋์ธ๋ฐ์. ์ด๊ฑด ์ ์ฒด์์ค๋ฅผ github๊ฐ์ ๊ณณ์ ์ฌ๋ ค์ฃผ์ ์ผ ํ์ธ ๊ฐ๋ฅํ ๊ฑฐ ๊ฐ๋ค์.๊ธฐ๋ณธ์ ์ผ๋ก ์คํ๋ง๋ถํธ๋ก ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ณ @Controller annotation์ ๋ถ์ด๋ฉด ๋น์ผ๋ก ๋ฑ๋ก๋์ด์ผ ํฉ๋๋ค.
- 0
- 3
- 358
Q&A
BCrypt ์ธ์ฆ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
ํํ ๋ฐฑ์ ์ฅ๋ .. ๋๋ฒ๊น ์ ํ๋ฉฐ ๋ถ์ํ๋ค ํ ์คํธ๋ฅผ ํด๋ดค๋๋์. String password = "!@#$password1234";String passwordHashed = BCrypt.hashpw(password, BCrypt.gensalt());String hashpw = BCrypt.hashpw(password, passwordHashed);System.out.println("first hashed = " + passwordHashed);System.out.println("second hashed = " + hashpw);first hashed = $2a$10$csCCTJlus2OXEyAHmYPmNOCtkEj8lv61WnJRVkVELo0GKjc4bIif. second hashed = $2a$10$csCCTJlus2OXEyAHmYPmNOCtkEj8lv61WnJRVkVELo0GKjc4bIif.์ด๋ ๊ฒ ๋์ค๋ค์. ์ฆ ์ฒซ ๋ฒ์งธ ์ธ์์ rawpassword, ๋ ๋ฒ์งธ ์ธ์์ ์ธ์ฝ๋ฉ๋ ๋น๋ฐ๋ฒํธ๋ฅผ ๋ฃ์ผ๋ฉด์ฒซ ๋ฒ์งธ ์ธ์ฅ์ rawpassword, ๋ ๋ฒ์งธ ์ธ์์ BCrypt.gensalt()๋ฃ์๋ ๊ฒฐ๊ณผ๊ฐ ๋๊ฐ์ด ๋์ค๊ฒ ๋๋๊ตฐ์.
- 1
- 9
- 1.5K
Q&A
BCrypt ์ธ์ฆ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
์ ๊ณ์ ์ ๋ง๋๋ ๋ถ๋ถ this.password = passwordEncoder.encode(this.password);์ ๋๋ฒ๊ทธ ํด๋ณด๋PasswordEncoderFactories ์์ bCrypt๋ฅผ ์์ฑํ ๋ SecureRandom random ์ธ์์ null์ ์ฃผ๋ฉดBCryptPasswordEncoder public String encode(CharSequence rawPassword) { String salt; if (strength > 0) { if (random != null) { salt = BCrypt.gensalt(strength, random); } else { salt = BCrypt.gensalt(strength); } } else { salt = BCrypt.gensalt(); }์์ ๋ณด์ด๋ฏ์ด gensalt๋ฅผ ์คํํด์ salt๋ฅผ ์ป๋๋ฐ์.์ด ๋ถ๋ถ์ ๋ฐ๋ณต์ ์ผ๋ก ์คํํด๋ณด๋ ํญ์ ๋ค๋ฅธ salt๊ฐ ๋์ค๋๋ฐ..๊ทธ๋ ๋ค๋ฉด ๊ณ ์ ๋ ๊ฐ์ด ์๋์ง ์๋์..?
- 1
- 9
- 1.5K
Q&A
BCrypt ์ธ์ฆ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
์ .. ๊ทธ๋ฐ๋ฐ ์ ๊ฐ ๊ถ๊ธํด์ ๋ ํ ์คํธ๋ฅผ ํด๋ดค๋๋ฐ์. String passwordHashed = BCrypt.hashpw(password, null);์ด๋ ๊ฒ ํ ์คํธ๋ฅผ ํ๋๋ salt๊ฐ์ผ๋ก null์ ๋ฃ์ ์ ์๋ค๊ณ ํ๋๋ฐ์คํ๋ง ์ํ๋ฆฌํฐ PasswordEncoderFactories์์๋ ์์ฑ์์์ null๋ก ์ ๋ ฅํด์ ํ๋๋ฐ๊ทธ ์ดํ์ ์ค์ ๋ก ์ด๋ป๊ฒ hashing์ ํ๋์ง ๊ทธ ๊ณผ์ ์ด ๊ถ๊ธํฉ๋๋ค.
- 1
- 9
- 1.5K
Q&A
๋น๋ฐ๋ฒํธ ๋น๊ต ๋ก์ง
์์ ์ด ๋ถ๋ถ์ ๋๋ฒ๊น ์ ํตํด์ ํด๊ฒฐํ์ต๋๋ค. ๊ถ๊ธ ํ์ ๋ถ๋ค์ DaoAuthenticationProvider class์ additionalAuthenticationChecks ๋ฉ์๋ ๋ถ๋ถ์ ๋ณด์๋ฉด ๋ ๊ฑฐ ๊ฐ์ต๋๋ค. ํน ๋๊ฐ ๊ถ๊ธํด ํ์ค๊น๋ด ์ง๋ฌธ ๋จ๊ฒจ๋์ต๋๋ค.
- 0
- 1
- 293
Q&A
BCrypt ์ธ์ฆ ๊ด๋ จ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
PasswordEncoderFactories์์ public static PasswordEncoder createDelegatingPasswordEncoder() { String encodingId = "bcrypt"; Map, PasswordEncoder> encoders = new HashMap(); encoders.put(encodingId, new BCryptPasswordEncoder()); encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());์ด๋ ๊ฒ ํ๊ณ public BCryptPasswordEncoder() { this(-1);}์ด๋ ๊ฒ public BCryptPasswordEncoder(int strength) { this(strength, null);}์ด๋ ๊ฒ ๋์ด์๋ค์..
- 1
- 9
- 1.5K