Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Android Java
Android Kotlin
Assembly
C
C3
Carbon
C++ (Circle)
CIRCT
Clean
CMake
CMakeScript
COBOL
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Cpp2-cppfront
Crystal
C#
CUDA C++
D
Dart
Elixir
Erlang
Fortran
F#
GLSL
Go
Haskell
HLSL
Hook
Hylo
IL
ispc
Java
Julia
Kotlin
LLVM IR
LLVM MIR
Modula-2
Nim
Objective-C
Objective-C++
OCaml
OpenCL C
Pascal
Pony
Python
Racket
Ruby
Rust
Snowball
Scala
Solidity
Spice
SPIR-V
Swift
LLVM TableGen
Toit
TypeScript Native
V
Vala
Visual Basic
WASM
Zig
Javascript
GIMPLE
Ygen
nim source #1
Output
Compile to binary object
Link to binary
Execute the code
Intel asm syntax
Demangle identifiers
Verbose demangling
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Debug intrinsics
Compiler
nim (trunk)
nim 1.0.4
nim 1.0.6
nim 1.2.0
nim 1.4.2
nim 1.4.4
nim 1.4.6
nim 1.4.8
nim 1.6.0
nim 1.6.16
nim 2.0.0
Options
Source code
# Code is based on https://forum.nim-lang.org/t/1305 # and https://forum.nim-lang.org/t/338 import macros, hashes type # Use a distinct string type so we won't recurse forever estring = distinct string # Use a "strange" name proc gkkaekgaEE(s: estring, key: int): string {.noinline.} = # We need {.noinline.} here because otherwise C compiler # aggresively inlines this procedure for EACH string which results # in more assembly instructions var k = key result = string(s) for i in 0 ..< result.len: for f in [0, 8, 16, 24]: result[i] = chr(uint8(result[i]) xor uint8((k shr f) and 0xFF)) k = k +% 1 var encodedCounter {.compileTime.} = hash(CompileTime & CompileDate) and 0x7FFFFFFF # Use a term-rewriting macro to change all string literals macro encrypt*{s}(s: string{lit}): untyped = var encodedStr = gkkaekgaEE(estring($s), encodedCounter) result = quote do: gkkaekgaEE(estring(`encodedStr`), `encodedCounter`) encodedCounter = (encodedCounter *% 16777619) and 0x7FFFFFFF echo "asgajklsgasjkg" echo "dhg3p-]2y=026yit02KEWGOY,Gasgajklsgasjkg" echo "asgajklsgasjkgas'asgklasgklasg" echo "asgajklsgasjkg4KYH4I023=Y=34JK20Y0=23GYJKJMDGHSFHG" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G" echo "asgajklsgasjkg34Y2YI=32T0Y23=Y0G"
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
CE on Mastodon
About the author
Statistics
Changelog
Version tree