Glen complained that the example in my previous post was pretty bad, so here is a better one in honor of Andy ;-)
<step name="md5-passwords" type="groovy">
<script>
import groovy.sql.Sql
import java.security.MessageDigest
sql = new Sql(connection)
sql.queryEach("select password, user_id from users") {
MessageDigest md = MessageDigest.getInstance("MD5")
sql.execute("update users set password=? where user_id=?",
[md.digest(it.password.bytes), it.user_id])
}
</script>
</step>
=)
writebacks...
Any particular need to create the MessageDigest inside the loop? md.reset() would be a lot quicker ;-)
md.reset
Much appreciated! In a real case I would also salt the password with the user_id and base64 encode it, but... this is an example before goign to bed ;-)
http://jboss.org
Umm, you're still breaking microsoft patent right?
Much better - thanks! Now all I need is a migration tool that will do cross database schema migration for my hibernate databases.
comment...