Chariot Training Classes

Training Courses

I run Chariot's training and mentoring services. We provide training in AngularJS, HTML5, Spring, Hibernate, Maven, Scala, and more.

Chariot Education Services

Technology

Chariot Emerging Tech

Learn about upcoming technologies and trends from my colleagues at Chariot Solutions.

Resources

Chariot Conferences

Podcasts

Entries in encryption (1)

Sunday
Feb192012

Quizzo in Roo - Security, SHA-256 and OS X

On OS X, there is no sha256sum utility, but a more generic one, shasum. This is good, but it takes standard input or a file, each of which will end up appending a newline on OS X.

Here was the workaround I found (thank you to this Stack Overflow thread).

echo -n passwd|shasum -a256

The -n flag strips the newline. The value I got for 'passwd' was 0d6be69b264717f2dd33652e212b173104b4a647b7c11ae72e9885f11cd312fb. Next, you can put the secure hash in applicationContext-security.xml like this:


<authentication-provider>
    <password-encoder hash="sha-256" />
    <user-service>
        <user name="admin"
          password="0d6be69b264717f2dd33652e212b173104b4a647b7c11ae72e9885f11cd312fb"
          authorities="ROLE_ADMIN,ROLE_USER" />
        <user name="user"
          password="0d6be69b264717f2dd33652e212b173104b4a647b7c11ae72e9885f11cd312fb" 
          authorities="ROLE_USER" />
    </user-service>
</authentication-provider>

On Unix systems, you'll be able to use sha256sum, presumably with the same echo -n input.