Created
June 4, 2012 10:28
-
-
Save PyYoshi/2867657 to your computer and use it in GitHub Desktop.
指定block sizeまでパッディングするlambda関数。 lambdaってちょー便利!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding:utf8 | |
| #!/usr/bin/env python | |
| mes = "python prpr" | |
| block_size = 32 | |
| padding = 'x' | |
| pad = lambda s: s + (block_size - len(s) % block_size) * padding | |
| print pad(mes) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ついでに16の倍数で埋める奴。気づく人は気づくであろうAESのpaddingに2つとも使ってます :)
pad16 = lambda s: s+(16-len(s))_padding if len(s)<16 else s+(16-(len(s)%16))_padding