Merge lp:~stefanor/ibid/crypto-391614 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Stefano Rivera
Approved revision: 675
Merged at revision: 676
Proposed branch: lp:~stefanor/ibid/crypto-391614
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/crypto-391614
Reviewer Review Type Date Requested Status
Michael Gorven Approve
Jonathan Hitchcock Approve
Review via email: mp+7987@code.launchpad.net

This proposal supersedes a proposal from 2009-06-24.

To post a comment you must log in.
Revision history for this message
Michael Gorven (mgorven) wrote : Posted in a previous version of this proposal

 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) wrote : Posted in a previous version of this proposal

base64 should match 'base10' as well as 'b10' etc, but ja.

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve
Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
lp:~stefanor/ibid/crypto-391614 updated
676. By Stefano Rivera

UTF-8 encode input data for crypt and hash

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/plugins/crypto.py'
--- ibid/plugins/crypto.py 2009-05-09 16:18:37 +0000
+++ ibid/plugins/crypto.py 2009-06-28 13:26:51 +0000
@@ -13,22 +13,35 @@
13 crypt <string> <salt>"""13 crypt <string> <salt>"""
14 feature = 'hash'14 feature = 'hash'
1515
16 @match(r'^(md5|sha1|sha224|sha256|sha384|sha512)\s+(.+?)$')16 @match(r'^(md5|sha1|sha224|sha256|sha384|sha512)(?:sum)?\s+(.+?)$')
17 def hash(self, event, hash, string):17 def hash(self, event, hash, string):
18 event.addresponse(eval('hashlib.%s' % hash.lower())(string).hexdigest())18 func = getattr(hashlib, hash.lower())
19 event.addresponse(unicode(func(string).hexdigest()))
1920
20 @match(r'^crypt\s+(.+)\s+(\S+)$')21 @match(r'^crypt\s+(.+)\s+(\S+)$')
21 def handle_crypt(self, event, string, salt):22 def handle_crypt(self, event, string, salt):
22 event.addresponse(crypt(string, salt))23 event.addresponse(unicode(crypt(string, salt)))
2324
24help['base64'] = u'Encodes and decodes base 16, 32 and 64.'25help['base64'] = u'Encodes and decodes base 16, 32 and 64. Assumes UTF-8.'
25class Base64(Processor):26class Base64(Processor):
26 u"""b(16|32|64)(encode|decode) <string>"""27 u"""base(16|32|64) (encode|decode) <string>"""
27 feature = 'base64'28 feature = 'base64'
2829
29 @match(r'^b(16|32|64)(enc|dec)(?:ode)?\s+(.+?)$')30 @match(r'^b(?:ase)?(16|32|64)\s*(enc|dec)(?:ode)?\s+(.+?)$')
30 def base64(self, event, base, operation, string):31 def base64(self, event, base, operation, string):
31 event.addresponse(eval('base64.b%s%sode' % (base, operation.lower()))(string))32 operation = operation.lower()
33 func = getattr(base64, 'b%s%sode' % (base, operation))
34 if operation == 'dec':
35 try:
36 bytes = func(string)
37 event.addresponse(u"Assuming UTF-8: '%s'", unicode(bytes, 'utf-8', 'strict'))
38 except TypeError, e:
39 event.addresponse(u"Invalid base%(base)s: %(error)s",
40 {'base': base, 'error': unicode(e)})
41 except UnicodeDecodeError:
42 event.addresponse(u'Not UTF-8: %s', unicode(repr(bytes)))
43 else:
44 event.addresponse(unicode(func(string.encode('utf-8'))))
3245
33help['rot13'] = u'Transforms a string with ROT13.'46help['rot13'] = u'Transforms a string with ROT13.'
34class Rot13(Processor):47class Rot13(Processor):

Subscribers

People subscribed via source and target branches