python:samba: add a generic string_to_byte_array() helper function
authorStefan Metzmacher <metze@samba.org>
Thu, 28 Jan 2016 12:44:33 +0000 (13:44 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Feb 2016 07:33:11 +0000 (08:33 +0100)
We should avoid implementing this again and again.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/__init__.py

index b04e83cd1151b4d5461a9537f9f13cc2c360aeae..59b6ebf5e618ecdb11e24a1449dc5a7017792116 100644 (file)
@@ -362,6 +362,14 @@ def dn_from_dns_name(dnsdomain):
 def current_unix_time():
     return int(time.time())
 
+def string_to_byte_array(string):
+    blob = [0] * len(string)
+
+    for i in range(len(string)):
+        blob[i] = ord(string[i])
+
+    return blob
+
 import _glue
 version = _glue.version
 interface_ips = _glue.interface_ips