A method of securing a software code comprising at least one constant value, said method generating a secure software code and comprising the steps of: - determining by a processor in the software code a constant value to be protected, - inserting by the processor in the software code an indexed array of values such that the constant value to be protected can be determined from one value of the array, - replacing by the processor in the software code the constant value to be protected by a replacement variable, - inserting by the processor in the software code a first sequence of instructions which, when executed at runtime: ∘ computes the index (i) in the array of the value from which the constant value to be protected can be determined, ∘ extracts from said array the value located at said computed index (i) in said array, ∘ from said extracted value, determines the constant value to be protected, ∘ sets the value of said replacement variable equal to the determined constant value, wherein the first sequence of instructions comprises a second sequence of instructions which, when executed at runtime, returns a first intermediate value (v), and a third sequence of instructions which, when executed at runtime, applies a first transformation function (f) to said first intermediate value (v) to compute said index (i) and wherein the first transformation function (f) is selected at random in a first set of predetermined transformation functions. - determining by a processor in the software code a constant value to be protected, - inserting by the processor in the software code an indexed array of values such that the constant value to be protected can be determined from one value of the array, - replacing by the processor in the software code the constant value to be protected by a replacement variable, - inserting by the processor in the software code a first sequence of instructions which, when executed at runtime: ∘ computes the index (i) in the array of the value from which the constant value to be protected can be determined, ∘ extracts from said array the value located at said computed index (i) in said array, ∘ from said extracted value, determines the constant value to be protected, ∘ sets the value of said replacement variable equal to the determined constant value, wherein the first sequence of instructions comprises a second sequence of instructions which, when executed at runtime, returns a first intermediate value (v), and a third sequence of instructions which, when executed at runtime, applies a first transformation function (f) to said first intermediate value (v) to compute said index (i) and wherein the first transformation function (f) is selected at random in a first set of predetermined transformation functions. ∘ computes the index (i) in the array of the value from which the constant value to be protected can be determined, ∘ extracts from said array the value located at said computed index (i) in said array, ∘ from said extracted value, determines the constant value to be protected, ∘ sets the value of said replacement variable equal to the determined constant value, wherein the first sequence of instructions comprises a second sequence of instructions which, when executed at runtime, returns a first intermediate value (v), and a third sequence of instructions which, when executed at runtime, applies a first transformation function (f) to said first intermediate value (v) to compute said index (i) and wherein the first transformation function (f) is selected at random in a first set of predetermined transformation functions.