# Chapter 20: Low-Level Programming¶

## Example xor.c, Page 515¶

In [17]:
KEY='&'
orig=raw_input()
orig_char=list(orig)
new_char=[]

def sxor(s1,s2):
return ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))
for i in orig_char:
N=sxor(i,KEY)
new_char.append(N)
print ''.join(new_char)

Trust not him with your secrets, who, when left alone in your room, turns over your papers. Johann Kaspar Lavater
rTSURHIRNOKQORN_ISTUCETCRU
QNI
QNCHJC@RGJIHCOH_ISTTIIK
RSTHUIPCT_ISTVGVCTUlINGHHmGUVGTjGPGRCT


## Example viewmemory.c, Page 521¶

In [11]:
from itertools import product
def main():

i=0
n=0
print "Address of main function: %s" % hex(id(main))
n=int(raw_input( "Enter number of bytes to view: "))
#printf("\n");
print " - - - - - - - - - - - - - - - - - - - - - - "
for nn in range(n,0,-10):
# for i,i in product(range(0//10), range(0//n)) :
#print "%.2X ", *(ptr + i));
#for (; i <10; i++)
# printf(" ");                    #pointer dereferencing not in python
#printf(" ");
#for (i = 0; i < 10 && i < n; i++) {
# BYTE ch = *(ptr + i);
#if (!isprint(ch))
#    ch = '.';
# printf("%c", ch);
#}
#printf("\n");
#ptr += 10;
#}
#return 0;
#}
if  __name__=='__main__':
main()

Address of main function: 0x4117eb8L