This file contains 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
! Flexoki color scheme for the X Window System | |
! | |
! https://stephango.com/flexoki | |
! Dark Tones | |
#define yellow #AD8301 | |
#define orange #BC5215 | |
#define red #AF3029 | |
#define magenta #A02F6F | |
#define violet #5E409D |
This file contains 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
class StreamCrypto | |
def self.aes_ctr_encrypt(clear_text,nonce,key) | |
counter=nonce.unpack('q')[0] | |
keystream = "" | |
cipher = OpenSSL::Cipher.new 'aes128' | |
cipher.padding=0 | |
cipher.encrypt | |
cipher.key=key | |
(Float(clear_text.length)/key.length).ceil().times do | |
stream_nonce="\0"*8+[counter].pack('q') |
This file contains 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
class String | |
def pkcs7strip | |
str=self.clone | |
# look at the last byte to determine padding amount | |
nbytes=str.bytes[-1] | |
# look at length-nbytes and make sure that it is also nbytes | |
# slice off nbytes and verify that each on is nbytes | |
if str.bytes[-nbytes] != nbytes | |
raise EncodingError,"Invalid PKCS7 Padding" | |
end |
This file contains 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
def challenge17 | |
server = CBCPaddingServer.new | |
iv,session_cookie = server.get_session_cookie() | |
block_size=16 | |
puts session_cookie.blocks(block_size).length | |
blocks=session_cookie.blocks(block_size) | |
blocks=[iv]+blocks | |
decoded_byte_string=[] | |
1.upto(blocks.length-1) do |bi| | |
decoded_bytes=[] |
This file contains 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
# Cipher text is a bytestring | |
# bi is the block index, or which block to edit. Flipping a bit in this block will result in a one bit edit in the bi+1 plaintext block | |
# i is the targeted bit's index | |
# z is the array of decoded bytes. | |
# The idea here is to target bit i, but also flip the bits of previously discovered bytes. | |
def flip_bit(cipher_text,bi,i,z) | |
bsize=16 | |
i.times do |j| | |
tb=(z[j-1]==nil) ? 0 : z[j-1] | |
cb=cipher_text.bytes()[bi*bsize-j-1] |
This file contains 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
class CryptoTools | |
def self.xor_str(str_a,str_b) | |
if str_a.length != str_b.length | |
raise "Length of input strings doesn't match!" | |
end | |
str_a.bytes.zip(str_b.bytes).map{ |x,y| x^y }.pack("C*") | |
end | |
def self.hex_xor(hex_a,hex_b) | |
Converters.str_to_hex(xor_str(Converters.hex_to_bytes(hex_a), | |
Converters.hex_to_bytes(hex_b))) |
This file contains 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
(defun hello-world (width height &optional (host "")) | |
(let* ((display (xlib:open-display host)) | |
(screen (first (xlib:display-roots display))) | |
(black (xlib:screen-black-pixel screen)) | |
(white (xlib:screen-white-pixel screen)) | |
(root-window (xlib:screen-root screen)) | |
(grackon (xlib:create-gcontext | |
:drawable root-window | |
:foreground white | |
:background black)) |
This file contains 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
(defun install-required-packages (package-list) | |
(when (>= emacs-major-version 24) | |
(package-refresh-contents) | |
(mapc (lambda (package) | |
(unless (require 'package nil t) | |
(package-install 'package))) | |
package-list))) | |
(setq required-package-list '(bm icicles smex zenburn-theme)) | |
(install-required-packages required-package-list) |
This file contains 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
;;;; -*- Mode: Lisp -*- | |
;; 20130620 (WBZ) This version of my .stumpwmrc is the culmination | |
;; of several days of study, experimentation, and asking of help | |
;; from others. (Beginning on 20130609.) | |
;; | |
;; This file is called "~/bin/stump/my.stumpwmrc" and is symbolically | |
;; linked as follows: | |
;; | |
;; $ cd; ln -s ~/bin/stump/my.stumpwmrc .stumpwmrc |
This file contains 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
{ | |
float binWeights[12]={180,135,120,105,76,68,60,41,30,35,26,18}; | |
TH1F kDecayHist("kDecayHist", "Decay length of K^{0} decays;decay length(cm);events",12,0,60); | |
for(int i=0; i < kDecayHist.GetNbinsX(); ++i){ | |
kDecayHist.SetBinContent(i+1,binWeights[i]); | |
} | |
//recreate overwrites any old files and puts our new stuff inside without warning! | |
TFile f("kaondecay.root","RECREATE"); |
NewerOlder