| Home | Trees | Indices | Help |
|
|---|
|
|
smartcard.util package
__author__ = "http://www.gemalto.com"
Copyright 2001-2011 gemalto Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com
This file is part of pyscard.
pyscard is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
pyscard is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with pyscard; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
PACK = 1
|
|||
HEX = 2
|
|||
UPPERCASE = 4
|
|||
COMMA = 8
|
|||
__dic_GSM_3_38__ =
|
|||
__package__ = Nonehash(x) |
|||
|
|||
Padds a byte list with a constant byte value (default is x0FF)
bytelist: the byte list to padd
length: the total length of the resulting byte list;
no padding if length is smaller than the byte list length
padding: padding value (default is 0xff)
returns the padded bytelist
example:
padd(toBytes("3B 65 00 00 9C 11 01 01 03"), 16) returns [0x3B, 0x65, 0, 0, 0x9C, 0x11, 1, 1, 3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
padd(toBytes("3B 65 00 00 9C 11 01 01 03"), 8) returns [0x3B, 0x65, 0, 0, 0x9C, 0x11, 1, 1, 3 ]
|
Returns a list of ASCII bytes from a string. stringtoconvert: the string to convert into a byte list returns a byte list of the ASCII codes of the string characters toASCIIBytes() is the reverse of toASCIIString() example: toASCIIBytes("Number 101") returns[ 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x20, 0x31, 0x30, 0x31 ] |
Returns a string representing a list of ASCII bytes. bytelist: list of ASCII bytes to convert into a string returns a string from the ASCII code list toASCIIString() is the reverse of toASCIIBytes() example: toASCIIString([ 0x4E, 0x75, 0x6D, 0x62, 0x65, 0x72, 0x20, 0x31, 0x30, 0x31 ]) returns "Number 101") |
Returns a list of bytes from a byte string bytestring: a byte string of the format "3B 65 00 00 9C 11 01 01 03" or "3B6500009C11010103" or "3B6500 009C1101 0103" |
Returns a list of bytes from a string using GSM 3.38 conversion table. stringtoconvert: string to convert returns a list of bytes example: toGSM3_38Bytes("@ùPascal") returns [ 0x00, 0x06, 0x50, 0x61, 0x73, 0x63, 0x61, 0x6C ] |
Returns an hex string representing bytes
bytes: a list of bytes to stringify, e.g. [59, 22, 148, 32, 2, 1, 0, 0, 13]
format: a logical OR of
COMMA: add a comma between bytes
HEX: add the 0x chars before bytes
UPPERCASE: use 0X before bytes (need HEX)
PACK: remove blanks
example:
bytes = [ 0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03 ]
toHexString(bytes) returns 3B 65 00 00 9C 11 01 01 03
toHexString(bytes, COMMA) returns 3B, 65, 00, 00, 9C, 11, 01, 01, 03
toHexString(bytes, HEX) returns 0x3B 0x65 0x00 0x00 0x9C 0x11 0x01 0x01 0x03
toHexString(bytes, HEX | COMMA) returns 0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03
toHexString(bytes, PACK) returns 3B6500009C11010103
toHexString(bytes, HEX | UPPERCASE) returns 0X3B 0X65 0X00 0X00 0X9C 0X11 0X01 0X01 0X03
toHexString(bytes, HEX | UPPERCASE | COMMA) returns 0X3B, 0X65, 0X00, 0X00, 0X9C, 0X11, 0X01, 0X01, 0X03
|
|
|||
__dic_GSM_3_38__
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sat Nov 22 15:23:51 2014 | http://epydoc.sourceforge.net |